import { NavBar } from 'antd-mobile';
import PropTypes from 'prop-types';
import React from 'react';
import { withRouter } from 'react-router-dom';
import './index.scss';

function NavHeader({ children, history, onLeftClick }) {

  const defaultHandle = () => history.go(-1);
  return (
    <NavBar
      className='NavHeader-comp'
      mode="light"
      icon={<i className='iconfont icon-back'></i>}
      onLeftClick={() => history.go(-1)}
      onLeftClick={onLeftClick || defaultHandle}
    >{children}</NavBar>
  );
}

NavHeader.propTypes = {
  children: PropTypes.string,
  onLeftClick: PropTypes.func
};

export default withRouter(NavHeader);